package demo;


import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test00 {

    //byType报错，找到多个bean
    @Test
    public void Test01(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");

        Animal p = (Animal) ac.getBean("animal");

        System.out.println(p.toString());

        ((ClassPathXmlApplicationContext)ac).close();
    }
    //byName报错，没找到bean
    @Test
    public void Test02(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        BigAnimal p2 = (BigAnimal) ac.getBean("animal");

        System.out.println(p2);

        ((ClassPathXmlApplicationContext)ac).close();
    }
}
